import * as crypto from 'crypto'

export function sha1(str: string){
    return crypto.createHash('sha1').update(str).digest('hex')
}

export function strpos(haystack: string, needle: string){
    const position = haystack.indexOf(needle)
    if(position === -1){
        return false
    }
    return position
}

export function ltrim(str: string, character_mask?: string ){
    if(character_mask && str.indexOf(character_mask) === 0){
        return character_mask.slice(1)
    }
    return str.trimStart()
}

export function contains(str: string, search: string){
    if(str){
        return str.includes(search)
    }
    return false
}

export function ucFirst(str: string){
    return str[0].toUpperCase() + str.slice(1)
}